<?php
/**
 *  Flvmeister
 *  a multi-format video transcoder class written in PHP5 
 *  Copyright (C) 2008  Marco Fischer <marco@flvmeister.com>
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by    
 *  the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *
 */

/**
 * Provides encoder adapter for encoding unsing ffmpeg
 *
 * @author Marco Fischer <marco@flvmeister.com>
 * @copyright Copyright (C) 2008  Marco Fischer <marco@flvmeister.com>
 * @package Flvmeister
 * @version 0.1-dev
 */
class Flvmeister_Encoder_Ffmpeg extends Flvmeister_Encoder_Abstract
{
    function __construct(Flvmeister_Filter_Interface $filter)
    {
        if(!extension_loaded('ffmpeg'))
        {
            if (!dl('ffmpeg.so'))
            {
                throw new Flvmeister_Exception('cannot load php-extension ffmpeg');
                return false;
            }
        }
    }

    public function saveThumbnail( Flvmeister_Config_Thumbnail $tConfig )
    {
        $movie = new ffmpeg_movie( $tConfig->inputFile );
        $frame = $movie->getFrame(100);

        $img = $frame->toGDImage();

        imagejpeg($img, $tConfig->outputFolder.'/'.$tConfig->outputPrefix.'_'.$tConfig->tResolution.'.jpg');
        
        return true;
    }
    
    public function encodeVideo( Flvmeister_Config_Video $vConfig )
    {
        print_r($vConfig);
        return true;
    }



}